#ifndef DW_BASE_POINTER_H
#	define DW_BASE_POINTER_H

namespace dw {
	namespace base {

template< typename T >
class Pointer
{
public : //! @name Construction & destruction
	//! @{
	inline Pointer(T* ptr = NULL);
	inline Pointer(const Pointer< T >&);
	//! @}

	T& operator * () { return *_counter->ptr; }
	T* operator -> () { return _counter->ptr; }
	inline Pointer& operator = (const Pointer< T >&);

private : //! @name Types definitions
	//! @{
	struct Counter
	{
		T* ptr;
		dw::uint32 count;

		Counter(T* p = NULL, dw::uint32 c = 1) : ptr(p), count(c) {}
	};
	//! @}

private : //! @name Helpers
	//! @{
	void acquire(Counter*);
	void release();
	//! @}

private : //! @name Data
	//! @{
	Counter* m_counter;
	//! @}
};

	} // namespace base
} // namespace dw

#include "base/pointer.inl"

#endif // !DW_BASE_POINTER_H

